/*
 * Problem: A Simple Problem with Integers(POJ 3468)
 * Created: 2022/02/28
 * Author: Yuanshun L
 */

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define qc ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
const ll DAT_SIZE = (1<<18)-1;
// input
ll N,Q;

// data[i] means the increment number of a range corresponding to the i-th node.
ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k,int l,int r){
    if(a<=l && b>=r){
        data[k] += x;
    }
    else if(b>l && r>a){
        datb[k] += (min(r,b) - max(l,a)) * x;
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
    }
}

ll sum(int a,int b,int k,int l,int r){
    if(b <=l || r <= a) return 0;
    else if (a <=l && b>=r) return (r-l)*data[k] + datb[k];
    else{
        ll res = (min(r,b) - max(l,a)) * data[k];
        res += sum(a,b,k*2+1,l,(l+r)/2);
        res += sum(a,b,k*2+2,(l+r)/2,r);
        return res;
    }
}


void solve(){
    int N_;
    cin >> N_ >> Q;
    N = 1;
    while(N<=N_) N*=2;

    int t;
    for(int i=0;i<N_;i++){
        cin >> t;
        add(i,i+1,t,0,0,N);
    }
    string op;
    int l,r,x;
    for(int i=0;i<Q;i++){
        cin >> op >> l >> r;

        if(op[0] == 'Q'){
            cout << sum(l-1,r,0,0,N) << endl;
        }
        else{
            cin >> x;
            add(l-1,r,x,0,0,N);
        }
    }
}

int main(){
    qc;
//    freopen("data.in","r",stdin);
//    freopen("data.out","w",stdout);
    solve();
    return 0;
}
